package com.codingman.jdbcdemo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

//PreparedStatement
public class Demo2 {

	public static void main(String[] args) {
		try {
			Class.forName("com.mysql.cj.jdbc.Driver");

			Connection con = DriverManager.getConnection("jdbc:mysql://45.77.187.28:3306/codingdb", "codingman",
					"Cm@123456");

			PreparedStatement stmt=con.prepareStatement("insert into employee values(?,?,?)");  
			stmt.setInt(1, 101);
			stmt.setString(2, "Ann");
			stmt.setFloat(3, 100);
			
			int i = stmt.executeUpdate();  
			System.out.println(i+" records inserted");  
			
			con.close();

		} catch (Exception e) {
			System.out.println(e);
		}

	}

}
